﻿@model S4Store.Models.Report.CarModelTimeRateModel
@{
    Layout = null;
    ViewBag.Title = "CarModelTimeRate";
    var container = "div" + Guid.NewGuid().ToString();
    var brands = new List<String>();
    var data1 = new List<String>();
    var data2 = new List<String>();
    var diffs = new List<int>();
    foreach (var brand in Model.ModelDatas)
    {
        brands.Add("\"" + brand.CarModel.Name + "\"");
        data1.Add(brand.Rate.toInt());
        data2.Add(Model.DateRate.toInt());
        var diff = (int)(brand.Sale - brand.SaleTarget);
        diffs.Add(diff);


    }


    S4Store.Models.Chart.Column ChartModel = new S4Store.Models.Chart.Column();
    ChartModel.Name = "分车款销量时间进度差";
    ChartModel.YAxis = "进度百分比(%)";
    foreach (var report in Model.Reports)
    {
        ChartModel.XAxis.Add(report.CarModel.Name);
    }
    //ChartModel.Width = 500;
    ChartModel.Height = 300;
    //ChartModel.XAxis.Add("销售进度");
    //ChartModel.XAxis.Add("订单进度");

    S4Store.Models.Chart.ChartSeries series1 = new S4Store.Models.Chart.ChartSeries();
    series1.Name = "销售进度";
    foreach (var report in Model.Reports)
    {
        series1.Data.Add(report.SaleRate);
    }
    ChartModel.Serieses.Add(series1);


    S4Store.Models.Chart.ChartSeries series2 = new S4Store.Models.Chart.ChartSeries();
    series2.Name = "时间进度";
    foreach (var report in Model.Reports)
    {
        series2.Data.Add(report.RateOfTime);
    }
    ChartModel.Serieses.Add(series2);


    List<S4Store.Models.Chart.RedGreenIndex> RedGreenIndexs = new List<S4Store.Models.Chart.RedGreenIndex>();
    foreach (var report in Model.Reports)
    {
        S4Store.Models.Chart.RedGreenIndex index = new S4Store.Models.Chart.RedGreenIndex();
        index.Size = S4Store.Models.Chart.RedGreenIndex.IndexSize.Middle;
        index.Title = "实际交车数与应时交车数的差值";
        index.Value = (report.SaleRateDiff * report.SaleTarget/100).AutoRound().ToString();
        if (report.SaleRateDiff >= 0)
        {
            index.Type = S4Store.Models.Chart.RedGreenIndex.IndexType.Green;
        }
        else
        {
            index.Type = S4Store.Models.Chart.RedGreenIndex.IndexType.Red;
        }
        RedGreenIndexs.Add(index);
    }
}
<div style="height:100%; overflow:auto">
@Html.Action("ReportBar", "Common", Model.BarModel)
<div style="position:relative; width:100%">
      
        @Html.Partial("../Chart/Column", ChartModel)
        @Html.Partial("../Chart/RedGreenIndex", RedGreenIndexs)
    
</div>
</div>